/-editor
/-files
FileEntry.ts
FileList.ts
FolderEntry.ts
functions.ts
/-files-old
/-imports
/-layout
/-storage
/-tests
/-tests/files
FileList.ts
/-tests/storage
TestCase.ts
TestPage.ts
_sampleTests.ts
/-typings
TypeScriptService.ts
functions.ts
ko.ts
persistence.ts
shell.ts
teapo.html
teapo.js
teapo.ts
x
              this._storage._savingCache.endSave(this.fullPath());
 
722
            alert('drop table ' + this._fullPath + ' ' + e.message);
723
          });
724
      }
725
    }
726
727
  }
728
729
  function getUniqueKey(): string {
730
    var key = window.location.href;
731
732
    key = key.split('?')[0];
733
    key = key.split('#')[0];
734
735
    if (key.length > 'index.html'.length
736
      && key.slice(key.length - 'index.html'.length).toLowerCase() === 'index.html')
737
      key = key.slice(0, key.length - 'index.html'.length);
738
739
    key += '*';
740
741
    return key;
742
  }
743
744
  function getOpenDatabase() {
745
    return typeof openDatabase == 'undefined' ? null : openDatabase;
746
  }
747
748
  function safeParseInt(str: string): number {
749
    if (!str) return null;
750
    if (typeof str === 'number') return <number><any>str;
751
    try {
752
      return parseInt(str);
753
    }
754
    catch (e) {
755
      return null;
756
    }
757
  }
758
759
  function appendScriptElement(doc: typeof document): HTMLScriptElement {
760
    var s = doc.createElement('script');
761
    s.setAttribute('type', 'text/data');
762
    doc.body.insertBefore(s, doc.body.children[0]);
763
    return s;
764
  }
765
766
  function removeScriptElement(script: HTMLElement) {
767
    var keepElement: boolean;
768
    if (script.tagName.toLowerCase() === 'style') {
769
      keepElement = true;
770
    }
771
    else if (script.tagName.toLowerCase() === 'script') {
772
      var type = script.getAttribute('type');
773
      if (!type || type.indexOf('javascript') > 0) {
774
        keepElement = true;
775
      }
776
      else {
777
        if (script.id === 'page-template'
778
          || script.id === 'folder-template'
779
          || script.id === 'file-template')
780
          keepElement = true;
781
      }
782
    }
783
784
    if (keepElement) {
785
      script.removeAttribute('data-path');
786
    }
787
    else {
788
      script.parentElement.removeChild(script);
789
    }
790
  }
791
792
  function loadPropertiesFromDom(
793
    tableName: string,
794
    script: HTMLScriptElement,
795
    properties: any,
796
    executeSql: ExecuteSqlDelegate) {
797
798
    function afterCreateTable(after: () => void) {
799
      if (executeSql) {
800
        executeSql(
801
          'CREATE TABLE "' + tableName + '" ( name TEXT, value TEXT)', [],
802
          (tr, r) => {
803
            after();
804
          },
805
          null);
806
      }
807
      else {
808
        after();
809
      }
810
    }
811
701:66